
/* Generated by Interface Builder */

#import "ShapeView.h"
#import <appkit/Matrix.h>
#import <dpsclient/wraps.h>
#import "shapes.h"

#define SQUARE  0
#define HEART   1
#define CIRCLE  2
#define DIAMOND 3
#define FLOWER  4
#define TRIANGLE  5
#define RECTANGLE  6

@implementation ShapeView

+newFrame:(const NXRect *)tF {
    self = [super newFrame:tF];
    numberTagValue = 5;
    shapeTagValue = CIRCLE;
	return self;
}

- shapeMatrix:sender
{
	shapeTagValue = [sender selectedTag];
	printf("shape = %d\n", shapeTagValue);
    [self display];
	return self;
}

- numberMatrix:sender
{
	numberTagValue = [sender selectedTag] + 1;
	printf("number = %d\n", numberTagValue);
    [self display];
    return self;
}

- drawSelf:(NXRect*)r :(int)c
{
int i;
    NXEraseRect(&bounds);
    PSsetgray(NX_BLACK);
    // PStranslate(bounds.size.width/2.0,  // -60.0*(10.0 - numberTagValue),
    //			bounds.size.height/2.0 -40.0*(10.0 - numberTagValue));
    PSscale(10.0/numberTagValue, 10.0/numberTagValue);
    for (i=0; i<numberTagValue; i++) {
    	switch (shapeTagValue) {
			case SQUARE:
				drawSquare();
				break;
			case HEART:
				drawHeart();
				break;
			case CIRCLE:
				drawCircle();
				break;
			case DIAMOND:
				drawDiamond();
				break;
			case FLOWER:
				drawFlower();
				break;
			case TRIANGLE:
				drawTriangle();
				break;
			case RECTANGLE:
				drawRectangle();
				break;
			default:
				printf("Error - no shape for number %d\n", shapeTagValue);
	    		break;
		}
	    PStranslate(100.0, 0.0);
	   }
    return self;
}

@end
